<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns="http://www.w3.org/1999/xhtml"
                template="./../home.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="content">
        <div class="col-lg-12">
            <h3 class="page-header" id="comercio">
                Administracion de Perfiles
                <h:link value="Regresar a Listado" outcome="list.xhtml" styleClass="pull-right" style="font-size: 16px; margin-right: 30px;"  />
            </h3>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-primary">
                    
                    <div class="panel-heading" style="font-weight: bold;">Registro de Perfiles</div>
                    <div class="panel-body">
                        <h:form id="frmRegistrarPerfil" styleClass="form-horizontal" >
                            <f:event type="preRenderView" listener="#{perfilControlador.initRegistrar}" />
                            <h:messages globalOnly="true" styleClass="list-group" infoClass="list-group-item list-group-item-success"
                                        errorClass="list-group-item list-group-item-danger" />
                            <div class="form-group has-feedback">
                                <label for="idperfil" style="font-size: 15px;" class="col-sm-2 control-label">Perfil :</label>
                                <div class="col-sm-5">
                                    <p:inputText styleClass="form-control" id="idperfil" value="#{perfilControlador.perfil.nombre}" />
                                </div>
                            </div>

                            <div class="form-group has-feedback">
                                <p:dataTable style="margin-left: 20px; margin-right: 20px;" value="#{perfilControlador.modulos}" var="list"  >
                                    <p:column>
                                        <f:facet name="header">
                                            Modulo
                                        </f:facet>
                                        #{list.nombre}
                                    </p:column>
                                    <p:column style="text-align: center;">
                                        <f:facet name="header">
                                            Listar
                                        </f:facet>
                                        <h:panelGroup rendered="#{list.listar eq true}">
                                            <p:selectBooleanCheckbox value="#{list.permiso.listar}" />
                                        </h:panelGroup>

                                    </p:column>
                                    <p:column style="text-align: center;">
                                        <f:facet name="header">
                                            Crear
                                        </f:facet>
                                        <h:panelGroup rendered="#{list.crear eq true}">
                                            <p:selectBooleanCheckbox value="#{list.permiso.crear}" />
                                        </h:panelGroup>
                                    </p:column>
                                    <p:column style="text-align: center;">
                                        <f:facet name="header">
                                            Actualizar
                                        </f:facet>
                                        <h:panelGroup rendered="#{list.actualizar eq true}">
                                            <p:selectBooleanCheckbox value="#{list.permiso.actualizar}" />
                                        </h:panelGroup>
                                    </p:column>
                                    <p:column style="text-align: center;">
                                        <f:facet name="header">
                                            Eliminar
                                        </f:facet>
                                        <h:panelGroup rendered="#{list.eliminar eq true}">
                                            <p:selectBooleanCheckbox value="#{list.permiso.eliminar}" />
                                        </h:panelGroup>
                                    </p:column>
                                </p:dataTable>
                            </div>

                            <br/>
                            <p:commandButton value="Guardar" actionListener="#{perfilControlador.registrarPerfil}" update="@form" styleClass="btn btn-primary" onstart="PF('blockUIWidget').block()"
                                                     oncomplete="PF('blockUIWidget').unblock();"/>
                            <pe:blockUI   widgetVar="blockUIWidget">  
                                <h:panelGrid columns="2">  
                                    <h:graphicImage library="images" name="cargar.gif"  
                                                    style="margin-right: 5px; vertical-align: middle;"/>  
                                    <h:outputText value="Espere ..." style="white-space: nowrap;"/>  
                                </h:panelGrid>  
                            </pe:blockUI>
                        </h:form>
                    </div>
                </div>
            </div>
        </div>
    </ui:define>

</ui:composition>
